home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DocUtilP.cpp
-
- Contains: Routines from DocUtils.cpp that are only used by the shell. They
- have been removed from DocUtils.cpp. DocUtils.cpp exposes
- private implementation of the shell, and we would like to
- remove the routines there from the public distribution.
-
- Owned by: Nick Pilch
-
- Copyright: 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 10/5/96 NP Comments concerning changes to DocUtils.
- <1> 18.09.1996 NP first checked in
-
- To Do:
- */
-
- #ifndef _DOCUTILP_
- #include "DocUtilP.h"
- #endif
-
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
-
- #ifndef SOM_ODDispatcher_xh
- #include "Disptch.xh"
- #endif
-
-
- #ifndef _DOCUTILS_
- #include "DocUtils.h"
- #endif
-
- #ifndef _STORUTIL_
- #include "StorUtil.h"
- #endif
-
- #ifndef _STDTYPIO_
- #include "StdTypIO.h"
- #endif
-
- #ifndef _TEMPOBJ_
- #include "TempObj.h"
- #endif
-
-
- const ODPropertyName kODPropTempDocument = "+//ISO 9070/ANSI::113722::US::CI LABS::OpenDoc:Property:TempDocument";
-
-
- //------------------------------------------------------------------------------
- // ODGetFirstOpenDocument
- //------------------------------------------------------------------------------
-
- ODDocument* ODGetFirstOpenDocument(Environment* ev, ODSession* session)
- {
- return ODGetNthOpenDocument(ev, session, 1);
- }
-
- //------------------------------------------------------------------------------
- // ODDeleteDocument
- //------------------------------------------------------------------------------
-
- ODBoolean ODDeleteDocument(Environment* ev, ODSession* session, ODDocument* document)
- {
- WASSERT(session != kODNULL);
- WASSERT(document != kODNULL);
-
- if (!session)
- THROW(kODErrIllegalNullInput);
- if (!document)
- THROW(kODErrIllegalNullDocumentInput);
-
- TempPlatformFile currentFile =
- GetPlatformFileFromContainer(ev, document->GetContainer(ev));
- ODBoolean retval = ODCloseDocument(ev, session, document);
- currentFile->MoveToTrash();
- return retval;
- }
-
- //------------------------------------------------------------------------------
- // ODRevertDocument
- //------------------------------------------------------------------------------
-
- void ODRevertDocument(Environment* ev, ODSession* session, ODDocument* document)
- {
- WASSERT(session != kODNULL);
- WASSERT(document != kODNULL);
- if (!session)
- THROW(kODErrIllegalNullInput);
- if (!document)
- THROW(kODErrIllegalNullDocumentInput);
-
- ODDraft* tempDraft = ODGetTempDraftFromOpenDocument(ev, session, document);
- if (tempDraft)
- {
- ODCloseDraft(ev, session, tempDraft);
- tempDraft->RemoveChanges(ev);
- ODOpenDraft(ev, session, tempDraft);
- // SyncFileToProperties(ev, session, document);
- session->GetDispatcher(ev)->InvalidateFacetUnderMouse(ev);
- }
- }
-
- //------------------------------------------------------------------------------
- // ODIsTempDocument
- //------------------------------------------------------------------------------
-
- ODBoolean ODIsTempDocument(Environment* ev, ODSession* session, ODDocument* document)
- {
- ODDraft* draft = ODGetTempDraftFromOpenDocument(ev, session, document);
- RETURN_IF_NULL(draft, kODFalse);
- TempODStorageUnit su = draft->AcquireDraftProperties(ev);
- if (!su->Exists(ev, kODPropTempDocument, kODBoolean, 0))
- return kODFalse;
- return ODGetBooleanProp(ev, su, kODPropTempDocument, kODBoolean);
- }
-
- //------------------------------------------------------------------------------
- // ODSetIsTempDocument
- //------------------------------------------------------------------------------
-
- void ODSetIsTempDocument(Environment* ev, ODDraft* draft, ODBoolean isTemp)
- {
- if (!draft)
- return;
- TempODStorageUnit su = draft->AcquireDraftProperties(ev);
- if (isTemp)
- ODSetBooleanProp(ev, su, kODPropTempDocument, kODBoolean, isTemp);
- else
- ODSURemoveProperty(ev, su, kODPropTempDocument);
- }
-
-